/**
 * Represents a review with id, username, movie title, movie year, comment, and rating.
 * @author mmuppa and klw4z
 *
 */
public class Review {
	private static int IDCount = 3;
	
	private int reviewID;
	private String reviewUsername;
	private String reviewMovieTitle;
	private int reviewMovieYear;
	private String comment;
	private int reviewRating;
	
	/**
	 * Initialize the review parameters.
	 * 
	 * @throws IllegalArgumentException if title or genre or studio name are null or empty,
	 * length <= 0, year < 1920.
	 */
	public Review(String username, String title, int year, String comment, int rating) {
		setID();
		setReviewUsername(username);
		setReviewMovieTitle(title);
		setReviewMovieYear(year);
		setComment(comment);
		setReviewRating(rating);
	}
	
	@Override
	public String toString()
	{
		return "Review [id=" + reviewID + ", username=" + reviewUsername + ", movie="
				+ reviewMovieTitle + ", movie year=" + reviewMovieYear + ", comment=" + comment
				+ " rating= " + reviewRating + "]";
	}
	
	public int getReviewID()
	{
		return this.reviewID;
	}
	
	private void setID()
	{
		this.reviewID = IDCount;
		IDCount++;
	}
	
	/**
	 * Returns the username.
	 * @return movie title
	 */
	public String getReviewUsername()
	{
		return reviewUsername;
	}
	
	/**
	 * Modifies the username.
	 * @param user
	 * @throws IllegalArgumentException if title is null or empty.
	 */
	public void setReviewUsername(String user)
	{
		if (user == null || user.length() == 0 )
			throw new IllegalArgumentException("Please supply a valid username.");
		this.reviewUsername = user;
	}

	/**
	 * Returns the title of the movie.
	 * @return movie title
	 */
	public String getReviewMovieTitle()
	{
		return reviewMovieTitle;
	}
	
	/**
	 * Modifies the title of the movie.
	 * @param title
	 * @throws IllegalArgumentException if title is null or empty.
	 */
	public void setReviewMovieTitle(String title)
	{
		if (title == null || title.length() == 0 )
			throw new IllegalArgumentException("Please supply a valid title.");
		this.reviewMovieTitle = title;
	}
	
	/**
	 * Returns the year the movie was made.
	 * @return year
	 */
	public int getReviewMovieYear()
	{
		return reviewMovieYear;
	}
	
	/**
	 * Sets the movie year.
	 * @param year
	 * @throws IllegalArgumentException if year is before 1920. 
	 */
	public void setReviewMovieYear(int year)
	{
		if (year < 1920)
			throw new IllegalArgumentException("Movie year cannot be before 1920.");
		this.reviewMovieYear = year;
	}
	
	/**
	 * Returns the comment.
	 * @return reviewComment
	 */
	public String getComment()
	{
		return comment;
	}
	
	/**
	 * Modifies the comment.
	 * @param comment
	 * @throws IllegalArgumentException if comment is negative or 0.
	 */
	public void setComment(String comment)
	{
		if (comment == null || comment.length() == 0 )
			throw new IllegalArgumentException("Please supply a valid comment.");
		this.comment = comment;
	}
	
	/**
	 * Returns the rating of the movie.
	 * @return movieSynopsis
	 */
	public int getReviewRating()
	{
		return reviewRating;
	}
	
	/**
	 * Sets the rating of the movie.
	 * @param synopsis
	 */
	public void setReviewRating(int rating)
	{
		this.reviewRating = rating;
	}
}
